/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fr.monVehicule.presentation.entretients;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import fr.monVehicule.coordination.ajouter.entretiens.AfficherEntretiensProcessus;
import fr.monVehicule.entite.Entretient;
import fr.monVehicule.entite.Vehicule;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;

/**
 *
 * @author David
 */
public class AfficherEntretiensAction extends ActionSupport implements SessionAware {

    Map<String, Object> sessionMap;
    private Vehicule vehicule;
    private List<Entretient> listeEntretients = new ArrayList<Entretient>();

    public Vehicule getVehicule() {
        return vehicule;
    }

    @Override
    public String execute() {
        int idVehicule = (Integer) sessionMap.get("vehiculeSelected");
        AfficherEntretiensProcessus processus = new AfficherEntretiensProcessus(idVehicule);
        processus.execute();
        vehicule = processus.getVehicule();
        listeEntretients = processus.getListeEntretients();

        return SUCCESS;
    }

    @Override
    public void setSession(Map<String, Object> map) {
        this.sessionMap = map;
    }
}
